﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Progrom
{
    public partial class main : Form
    {
        public main()
        {
            InitializeComponent();
        }

        private bool isLogined = false; //保存登录凭证


        private void tsmLogin_Click(object sender, EventArgs e)
        {
            login Form = new login();    //实例化登录窗口
            tssMsg.Text = Form.Text;
            //Form.MdiParent = this;   //指定当前窗体为MDI父窗体
            //Form.Show();

            //检测用户是否点击过登录按钮
            if (Form.ShowDialog() == DialogResult.OK)
            {
                if ((bool)Form.Tag)  //登录成功
                {
                    isLogined=true;
                    tssMsg.Text="恭喜您！已经成功登录系统！";
                }
                else
                {
                    isLogined = false;
                    tssMsg.Text = "注意，必须先登录才能使用本系统";
                }
            }

        }


        //学生信息子窗体
        private void tsmNewStudent_Click(object sender, EventArgs e)
        {
            if (isLogined)
            {
                Students stu = new Students();   //创建子窗体对象
                stu.MdiParent = this;
                stu.Show();
                tssMsg.Text = stu.Text;
            }
            else
                tssMsg.Text = "注意，必须先登录才能使用本系统";
        }

        //课程信息子窗体
        private void tsmNewCourse_Click(object sender, EventArgs e)
        {
            if (isLogined)
            {
                infor Cform = new infor();   //创建子窗体对象
                Cform.MdiParent = this;
                Cform.Show();
                tssMsg.Text = Cform.Text;
            }
            else
                tssMsg.Text = "注意，必须先登录才能使用本系统";
        }

        private void tsmAbout_Click(object sender, EventArgs e)
        {
                about ab = new about();   //创建子窗体对象
                ab.MdiParent = this;
                ab.Show();
                tssMsg.Text = ab.Text;
        }

        private void tsmExit_Click(object sender, EventArgs e)
        {
            isLogined = false;   //退出登录
        }

        private void tsmStuMsgMag_Click(object sender, EventArgs e)
        {
            if (isLogined)
            {
                StudentsMsg form = new StudentsMsg();
                form.MdiParent = this;
                form.Show();
                tssMsg.Text = form.Text;
            }
            else
                tssMsg.Text = "注意，必须先登录才能使用本系统";
        }

        private void tsmCurMsgMag_Click(object sender, EventArgs e)
        {
            if (isLogined)
            {
                inforMsg infor = new inforMsg();
                infor.MdiParent = this;
                infor.Show();
                tssMsg.Text = infor.Text;
            }
            else
                tssMsg.Text = "注意，必须先登录才能使用本系统";
        }

        private void tsmScoreMsg_Click(object sender, EventArgs e)
        {
            if (isLogined)
            {
                ScourMsg Sform = new ScourMsg();   //创建子窗体对象
                Sform.MdiParent = this;
                Sform.Show();
                tssMsg.Text = Sform.Text;
            }
            else
                tssMsg.Text = "注意，必须先登录才能使用本系统";
        }






    }
}
